<template>
	<view class="u-page">
		<view class="u-demo-block">
			<view class="u-demo-block__content">
				<u-row customStyle="margin-bottom: 10px;margin-top:10px;">
					<u-col span="12">
						<u-button size="small" color="linear-gradient(to right, rgb(66, 83, 216), rgb(213, 51, 186))"
							text="通义千问" @click="taobao"></u-button>
					</u-col>
				</u-row>
				<u-row customStyle="margin-bottom: 10px;margin-top:10px;">
					<u-col span="12">
						<u--input placeholder="请输入内容" border="surround" clearable v-model="msg"></u--input>
					</u-col>
				</u-row>
				<u-row customStyle="margin-bottom: 10px;margin-top:10px;" style="width:100% ;">
					<u-col span="12">
						<view class="uni-textarea" style="width:100%;min-height: 500rpx;">
							<view><p>{{answer}}</p></view>
						</view>
					</u-col>
				</u-row>
				<u-row customStyle="margin-bottom: 10px;margin-top:10px;">
					<u-col span="12">
						<u-button type="warning" shape="circle" text="测试" @click="get"></u-button>
						<u-button type="error" text="退出" @click="quit"></u-button>
					</u-col>
				</u-row>
			</view>
		</view>
	</view>

</template>

<script>
	export default {
		data() {
			return {
				msg: "",
				answer: "..."
			}
		},
		methods: {
			taobao() {
				if (this.msg) {
					this.answer = "";
					this.$lApi({
						url: '/ai/one',
						method: 'POST',
						data: { "content": this.msg }
					}).then((res) => {
						console.log(res);
						if (res["code"] == this.$code.SUCCESS_CODE) {
							this.answer = res["data"]["msg"];
						}
					}, (err) => {
						console.log(err);
					});
				} else {
					this.$u.toast("问题为空");
				}
			},
			get() {
				this.$lApi({
					url: '/user/get',
					method: 'POST',
				}).then((res) => {
					console.log("res", res);
				}, (err) => {
					console.log("err", err);
				});
			},
			quit() {
				uni.reLaunch({
					url: '/pages/login/login'
				});
				uni.clearStorageSync();
			},
		}
	}
</script>

<style lang="less" scoped>

</style>